package com.hnhuas.salary.modules.admin.service.impl;

import cn.hutool.core.convert.Convert;
import com.hnhuas.salary.common.utils.PageUtils;
import com.hnhuas.salary.common.utils.Query;
import com.hnhuas.salary.modules.admin.dao.SalaryUserDao;
import com.hnhuas.salary.modules.admin.entity.SalaryUserEntity;
import com.hnhuas.salary.modules.admin.service.SalaryUserService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



@Service("salaryUserService")
public class SalaryUserServiceImpl extends ServiceImpl<SalaryUserDao, SalaryUserEntity> implements SalaryUserService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        boolean is_admin= Convert.toBool(params.get("is_admin"));

        IPage<SalaryUserEntity> page = this.page(
                new Query<SalaryUserEntity>().getPage(params),
                new QueryWrapper<SalaryUserEntity>().eq("is_admin",is_admin)
        );

        return new PageUtils(page);
    }

    @Override
    public SalaryUserEntity queryByUserName(String username) {
        QueryWrapper<SalaryUserEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("identity_card",username);
        return this.getOne(queryWrapper);
    }

}
